package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsAddressMapper;
import com.qf.pojo.DtsAddress;
import com.qf.service.DtsAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/24 14:06
 */
@Service
public class DtsAddressServiceImpl implements DtsAddressService {

    @Autowired
    private DtsAddressMapper dtsAddressMapper;

    /**
     * 地址查询
     * @param page
     * @param limit
     * @param sort
     * @param order
     * @param name
     * @return
     */
    @Override
    public IPage<DtsAddress> findListByQuery(Integer page, Integer limit, String sort, String order, String name,Integer userId) {
        return dtsAddressMapper.selectPage(new Page(page,limit),
                new QueryWrapper<DtsAddress>()
                        .like(!StringUtils.isEmpty(name),"name",name)
                        .like(!StringUtils.isEmpty(userId),"user_id",userId)
                        .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
